#include <iostream>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
    int n; cin >> n;
    vector<int> vec(n);
    for(auto & item : vec){
        cin >> item;
    }
    sort(vec.begin(), vec.end());

    int cnt = 0;
    for(int i = 0, j = 1; i < n - 1 && j < n; i += 2, j += 2){
        cnt += vec[j] - vec[i];
    }
    cout << cnt;
    return 0;
}